/// <reference path="../../sage/sage.util.js" />

var ThreeDimensionalPainter = Base.extend({
    initialize: function initialize() { },
    paint: function paint(context) {
        context.gameObject.updateLocation(context);
        if (context.gameObject.visible) {
            var rect = context.gameObject.locationRelativeToCamera.objectRectangle;
            var polygons = context.gameObject.relativePolygons;
            var paintables = [];
            var lyr = context.frontLayer;

            for (var i = 0; i < polygons.length; i++) {
                var poly = polygons[i];

                // draw em?
                lyr.fillStyle = (poly.color != null) ? poly.color : "#FF0000";

                var prevPt = poly.points[poly.points.length - 1];
                lyr.moveTo(prevPt.x, prevPt.y);

                for (var j = 0; j < poly.points.length; j++) {
                    var pt = poly.points[j];
                    lyr.lineTo(pt.x, pt.y);
                }
                lyr.closePath();
                lyr.fill();
            }
        }
    }
});
